﻿using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using CE.Database;


/// <summary>
/// Summary description for CXCarDriverMoreDetailDB
/// </summary>
namespace CE.CarInsurance
{
    public class CXCarDriverMoreDetailDB
    {
        public CXCarDriverMoreDetailDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(CXCarDriverMoreDetail cxcardrivermoredetail)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocCXCRMDriverMoreDetailInsertUpdateSingleItem";
            SortedList _sPara = new SortedList();
            #region Parameter
            _sPara.Add("@DriverDetailId", cxcardrivermoredetail.DriverDetailId);
            _sPara.Add("@CECarId", cxcardrivermoredetail.CECarId);
            _sPara.Add("@RefCEUserId", cxcardrivermoredetail.RefCEUserId);
            _sPara.Add("@AgentId", cxcardrivermoredetail.AgentId);
            _sPara.Add("@DriverId", cxcardrivermoredetail.DriverId);
            _sPara.Add("@Name", cxcardrivermoredetail.Name);
            _sPara.Add("@NRIC", cxcardrivermoredetail.NRIC);
            _sPara.Add("@LicensePassDate", cxcardrivermoredetail.LicensePassDate);
            _sPara.Add("@Relation", cxcardrivermoredetail.Relation);
            _sPara.Add("@Status", cxcardrivermoredetail.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);
            return _result;
        }

        public DataSet GetCXDriverMoreDetailDS(Int64 CECarId, Int64 RefCEUserId)
        {
            DataSet _dsCallStatus = null;
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocCXCRMDriverMoreDetailSelectSingleItem]";

            SortedList _spara = new SortedList();
            _spara.Add("@CECarId", CECarId);
            _spara.Add("@RefCEUserId", RefCEUserId);

            using (DataSet _ds = _db.GetDataSet(_spName, _spara))
            {
                if (_ds != null && _ds.Tables[0].Rows.Count > 0)
                {
                    _dsCallStatus = _ds;
                }
            }
            return _dsCallStatus;
        }

    }
}